var RerenderProList = function () {
    $('[title]').qtip({
        position: {
            target: 'mouse',
            adjust: { x: 15, y: 15, mouse: true }
        }
    });

    var productItem = $('li.list-items');

    productItem.each(function (i) {
        if ((i + 1) % 4 == 0) {
            productItem.eq(i).addClass('last');
        }
    });
    setTimeout(function () {
        productItem.find('img').each(function (i, data) {
            var img = $(data);
            img.attr("src", img.attr("data-src"));
        });
    }, 100);
    setTimeout(function () {
        productItem.find('img').zoomImgRollover({
            percent: 10,
            duration: 300
        });
    }, 200);
}

var switchViewStyle = function () {
    var target = $('.product-list-body');

    if ($.cookie("showListsStatus") == "lists") {
        $('#show-lists').addClass('on');
        $('#show-grids').removeClass('on');
        target.addClass('lists');
    }
    else {
        $('#show-grids').addClass('on');
        $('#show-lists').removeClass('on');
        target.removeClass('lists');
    }

    $('#show-grids').on('click', function () {
        $(this).addClass('on');
        $('#show-lists').removeClass('on');
        target.removeClass('lists');

        $.cookie("showListsStatus", "grids", { expires: 7 });
    });
    $('#show-lists').on('click', function () {
        $(this).addClass('on');
        $('#show-grids').removeClass('on');
        target.addClass('lists');

        $.cookie("showListsStatus", "lists", { expires: 7 });
    });
}

$(document).ready(function () {
    $('.category-sub-bellows').bellows({
        singleItemOpen: true
    });
    //$('#equalize').equalHeights();
    switchViewStyle();
    imagesLoaded('.product-list-body', RerenderProList());
});